//
//  ActitySecondCell.m
//  A段项目
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ActitySecondCell.h"
#import "Model.h"
#import <UIImageView+WebCache.h>
#import <DKNightVersion.h>

@interface ActitySecondCell ()

@property (nonatomic, retain) UIImageView *bigImage;
@property (nonatomic, retain) UIImageView *smallImage;
@property (nonatomic, retain) UIImageView *collectImage;

@property (nonatomic, retain) UILabel *nameLabel;
@property (nonatomic, retain) UILabel *numberLabel;

@property (nonatomic, retain) UILabel *backLabel;


@end

@implementation ActitySecondCell

- (void)dealloc {
    
    [super dealloc];
    
    [_bigImage release];
    [_smallImage release];
    [_collectImage release];
    
    [_nameLabel release];
    
    [_numberLabel release];
    
}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.backLabel = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.backLabel];
        
        self.bigImage = [[UIImageView alloc] init];
        
        self.smallImage = [[UIImageView alloc] init];
        
        self.collectImage = [[UIImageView alloc] init];
        
        self.nameLabel = [[UILabel alloc] init];
        
        self.numberLabel  = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.bigImage];
        
         [self.contentView addSubview:self.smallImage];
        
         [self.contentView addSubview:self.collectImage];
        
        [self.contentView addSubview:self.nameLabel];
        
        [self.contentView addSubview:self.numberLabel];
        
        [_bigImage release];
         [_smallImage release];
         [_collectImage release];
        
        [_backLabel release];
        
        [_nameLabel release];
        
        [_numberLabel release];
        
        
        
    }
    
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.bigImage.frame = CGRectMake(5, 0,self.frame.size.width - 10, self.frame.size.height - 50);
    
    self.smallImage.frame = CGRectMake(10,self.frame.size.height - 45,30,30);
    
    self.collectImage.frame = CGRectMake(self.frame.size.width - 40,self.frame.size.height - 45,20,20);
    
    self.nameLabel.frame = CGRectMake(42, self.frame.size.height - 45, 100, 30);
    
   
    
    self.numberLabel.frame = CGRectMake(self.frame.size.width - 40,self.frame.size.height - 30,30,15);
    
    self.backLabel.backgroundColor = [UIColor grayColor];
    
    self.backLabel.frame = CGRectMake(0, self.frame.size.height - 7, self.frame.size.width, 5);
  
    self.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:0.6 green:0.6 blue:0.4 alpha:0.8], [UIColor colorWithRed:52 / 256.f green:52 / 256.f blue:52 / 256.f alpha:1]);
    
    
    self.nameLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.numberLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);

    
    
    

}

- (void)passedInfo:(Model *)model {
    
    self.smallImage.layer.cornerRadius = 15;
//    
    self.smallImage.layer.masksToBounds = YES;
    
    [self.bigImage sd_setImageWithURL:[NSURL URLWithString:model.imageUrl]];
    
    [self.smallImage sd_setImageWithURL:[NSURL URLWithString:[model.user objectForKey:@"avatar"]]];
    
    self.collectImage.image = [UIImage imageNamed:@"xin"];
    
    self.nameLabel.text = [model.user objectForKey:@"nickName"];
    
    NSString *str = [NSString stringWithFormat:@"%ld",model.voteAmount];
//    
    self.numberLabel.text = [NSString stringWithString:str];
    self.numberLabel.font = [UIFont systemFontOfSize:10];
    
    
}







- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
